﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace nplJobsDAL.Delete
{
    public class DeleteJobSeekerEducationInfo : DataAccessBase
    {
        public long EducationInfoID { get; set; }

        public bool isDeleted;

        public DeleteJobSeekerEducationInfo()
        {
            StoredProcedureName = StoredProcedure.Name.spDeleteJobSeekerEducationInfoByID.ToString();
        }

        public void invoke()
        {
            DeleteJobSeekerEducationInfoDataParameters contactUpdateDataParameters = new DeleteJobSeekerEducationInfoDataParameters(this.EducationInfoID);
            DataBaseHelper dbHelper = new DataBaseHelper(StoredProcedureName);
            dbHelper.Parameters = contactUpdateDataParameters.Parameters;
            dbHelper.RunScalar();

            if (contactUpdateDataParameters.Parameters[1].Value != null)
            {
                isDeleted = contactUpdateDataParameters.Parameters[1].Value.ToString() == "1" ? true : false;
            }
        }
    }

    #region SQL Parameters for  Delete
    public class DeleteJobSeekerEducationInfoDataParameters
    {
        public long EducationInfoID { get; set; }

        int isDeleted = 0;

        public DeleteJobSeekerEducationInfoDataParameters(long pi)
        {
            this.EducationInfoID = pi;
            Build();
        }

        private void Build()
        {
            SqlParameter[] parameters = 
                {
                    new SqlParameter("@EducationInfoID", EducationInfoID),
                    new SqlParameter("@IsDeleted",isDeleted){ Direction =System.Data.ParameterDirection.Output}
                };

            Parameters = parameters;
        }

        public SqlParameter[] Parameters { get; set; }
    }
    #endregion
}
